﻿

<!--********************* Part1:Jsp Head *********************-->

<%@ page contentType="text/html;charset=UTF-8"%>  
<%@ include file="/framework/head.jsp"%>

<!--********************* Part2:Java Code *********************-->
<%
    StorageMonthOutSearchEvent event = (StorageMonthOutSearchEvent)context.getSessionValue("StorageMonthOutSearchEvent");
    ObjectList list = StorageMonthOut.fetch().search(con,event);
%>

<!--********************* Part3:JavaScript Code ***************-->
<!--start 客户端脚本区域-->
<%@page import="system.base.StorageMonthOutSrv"%>
<%@page import="java.util.Vector"%>
<%@page import="system.data.StorageMonthOutPageData"%>
<%@page import="system.base.ProductCategory"%>
<%@page import="framework.core.StringUtil"%>
<script language=javascript>

var list_code = "listStorageMonthOut";

function doSearch()
{

    SetValue("s_BalanceTime",GetValue("i_Year")+ "-" + GetValue("i_Month")); //结算时间
    doCommonSearch();
}


key_InitDefault();
key_RegSubmitHandler(doSearch);
</script>


<%=uiBody%>>

<%@ include file="/framework/menu.jsp"%>

<!--********************* Part4:Form  ***************-->
<form id=frm action="<%=Config.getSrv()%>" method="post">
<input type=hidden name="action_code" value="">
<input type=hidden name="Id" value="">
<input type=hidden name=sortOrder value="1">

<!--查询条件保留区域-->


<%
String time = event.getBalanceTime();
String year = time.substring(0,4);
String month = time.substring(5,7);
%>
<input type=hidden name="s_BalanceTime" value="<%=event.getBalanceTime()%>"> <!--结算时间-->
<%@ include file="/framework/list_head.jsp"%>


<br>
<!--********************* Part5:Search Area ***************-->
<%=uiSearchStart%>>
<%
    int key_tab = 1 ;
%>

    <%=uiSearchInputTR%>>
        <%=uiSearchInputTDHead%>>
            选择结算月份：
        </td>
        <%=uiSearchInputTDHead%>>
            <%=SelectManager.viewYearSelect(con,"i_Year",year,false,"","-请选择-","","")%>  <%=SelectManager.viewMonthSelect(con,"i_Month",month,false,"","-请选择-","","")%><input type="button" value="查询" class="buttons" onclick="doSearch();return false;">&nbsp;<input type="button" value="清空" class="buttons" onclick="doClearEvent();return false;">
        </td>       
    </tr>    

<%=uiSearchEnd%>

<!--列表标题-->
<%=UIManager.addListHeadTitle(time + " 全体公司月分类明细")%>

<!--********************* Part6:List Area ***************-->
<%=uiListStart%>>

<%
boolean isfirst = false;
if(String.valueOf(context.getSessionValue("isfirst")) == "true"){
    isfirst = true;
}
    String balanceTime = (String)context.getSessionValue("s_BalanceTime");//获得之前作为条件的时间
    String menu = (String)context.getSessionValue("choice");//获得选定的菜单
    Vector vec = (Vector)context.getSessionValue(menu);//通过指定编号
%>
    <%int index = 1 ;%>  
    <%=uiListHeadTR%>>
        <%=UIManager.addListHead("公司名称",index++)%>
        <%=UIManager.addListHead("类别",index++)%>
        <%=UIManager.addListHead("金额(元)",index++,"num")%>
    <%=uiListHeadTREnd%>>
    <%
    double categoryMoney = 0;
    double totalMoney = 0;
    if(!isfirst && vec != null && vec.size() > 0){
        
  
        for(int k = 0; k < vec.size();k++){
            Vector detailVec = (Vector)vec.get(k);
            for(int i = 0; i < detailVec.size(); i++){
                StorageMonthOutPageData pd = (StorageMonthOutPageData)detailVec.get(i);
                ProductCategory pc = ProductCategory.fetchByCode(con, pd.getCategoryCode());
                if(pc == null) pc = ProductCategory.fetch();
                double detailMoney = StringUtil.strToDouble(pd.getProductMoney());
                categoryMoney += detailMoney;
                totalMoney += detailMoney;
                if(i == 0){
        %>
                <%=uiListDataTR[i%2]%> align=center>        
                    <%=uiListDataTD%> rowspan="<%= detailVec.size() %>"><%= pd.getWarehouseName() %></td>
                    <%=uiListDataTD%>><%= "自增分类".equals(pc.viewName(con)) ? "其他分类" : pc.viewName(con) %></td>
                    <%=uiListDataTD%>><%= StringUtil.showPrice(detailMoney, 2) %></td>        
                </tr><%}else{ %>
                <%=uiListDataTR[i%2]%> align=center>        
                    <%=uiListDataTD%>><%= "自增分类".equals(pc.viewName(con)) ? "其他分类" : pc.viewName(con) %></td>
                    <%=uiListDataTD%>><%= StringUtil.showPrice(detailMoney, 2) %></td>        
                </tr><%}
                if(i == detailVec.size() - 1){%>
                    <%=uiListDataTR[i%2]%> align=center>        
                    <%=uiListDataTD%> colspan="2">小计:</td>
                    <%=uiListDataTD%>><%= StringUtil.showPrice(categoryMoney, 2) %></td>     
                <% categoryMoney = 0;}
            }%>   
        <%}%>      
    </tr>
            <%=uiListDataTR[0]%> align=center>        
                <%=uiListDataTD%> colspan = "2">合计:</td>
                <%=uiListDataTD%>><%= StringUtil.showPrice(totalMoney, 2) %></td>        
            </tr>
    <%} %>

<%=uiListEnd%>
</form>


<%@ include file="/framework/foot.jsp"%>

<!--
    Author    :Benny
    FileName  :/system/base/StorageMonthOutList.jsp
-->
